package com.api.task.deletetask;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.ITaskApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.TaskApiType;

@ContextConfiguration(locations = { "classpath:/task/task-context.xml" })
public class DeleteTaskTaskManager extends AbstractApiTest {

	@Value("#{group_toDelete[taskManager].appId}")
	private String taskManagerUrn;

	@Value("#{group_toDelete[taskManager].password}")
	private String taskManagerPassword;

	@Value("#{group_toDelete.urn}")
	private String groupUrn;

	private String taskUrn;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(taskManagerUrn, taskManagerPassword);

		this.taskUrn = getApi().getService(ITaskApiService.class)
				.createTask("Title", "desciption", null, null, null, TaskApiType.TASK, null, null, groupUrn, null).getObject();
	}

	@Test
	public void testDeleteTask() throws ZyncroApiException {

		getApi().getService(ITaskApiService.class).deleteTask(taskUrn);
	}
}
